const Babl *
babl_space_from_icc (const char *icc_data,
int icc_length,
+ BablIccIntent intent,
const char **error)
{
ICC *state = icc_state_new ((char*)icc_data, icc_length, 0);
sign_t profile_class, color_space;
+
if (!error) error = &int_err;
*error = NULL;
}
}
+ switch (intent)
+ {
+ case BABL_ICC_INTENT_RELATIVE_COLORIMETRIC:
+ /* that is what we do well */
+ break;
+ case BABL_ICC_INTENT_PERCEPTUAL:
+ /* if there is an A2B0 and B2A0 tags, we do not do what that
+ * profile is capable of - since the CLUT code is work in progress
+ * not in git master yet.
+ */
+ if (icc_tag (state, "A2B0", NULL, NULL) &&
+ icc_tag (state, "B2A0", NULL, NULL))
+ {
+ *error = "profile contains perceptual luts and perceptual was explicitly asked for, babl does not yet support CLUTs";
+ }
+ else
+ {
+ intent = BABL_ICC_INTENT_RELATIVE_COLORIMETRIC;
+ }
+ break;
+ case BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC:
+ *error = "absolute colormetric not implemented";
+ break;
+ case BABL_ICC_INTENT_SATURATION:
+ *error = "absolute stauration not supported";
+ break;
+ }
+
{
int offset, element_size;
if (!*error && icc_tag (state, "rTRC", &offset, &element_size))
*/
const Babl * babl_space (const char *name);
+typedef enum {
+ BABL_ICC_INTENT_PERCEPTUAL = 0,
+ BABL_ICC_INTENT_RELATIVE_COLORIMETRIC = 1,
+ BABL_ICC_INTENT_SATURATION = 2,
+ BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC = 3
+} BablIccIntent;
+
/**
* babl_space_from_icc:
*
* if an error occurs, NULL is returned and an error message
* is provided in error.
*
- * Create a babl space from an in memory ICC profile, the
- * profile does no longer need to be loaded for the space to work,
- * multiple calls with the same icc profile and same icc_transform
- * will result in the same space.
+ * Create a babl space from an in memory ICC profile, the profile does no
+ * longer need to be loaded for the space to work, multiple calls with the same
+ * icc profile and same intent will result in the same babl space.
+ *
+ * On a profile that doesn't contain A2B0 and B2A0 CLUTs perceptual and
+ * relative-colorimetric intents are treated the same.
*
* If a BablSpace cannot be created from the profile NULL is returned and a
* static string is set on the const char *value pointed at with &value
*/
const Babl *babl_space_from_icc (const char *icc_data,
int icc_length,
+ BablIccIntent intent,
const char **error);
/* babl_icc_get_key:
* "copyright", "manufacturer", "device", "profile-class", "color-space" and
* "pcs".
*/
+
char *babl_icc_get_key (const char *icc_data,
int icc_length,
const char *key,
free (str);
}
}
- babl = babl_space_from_icc (icc_data, icc_len, &error);
+ babl = babl_space_from_icc (icc_data, icc_len, 0, &error);
free (icc_data);
if (error || !babl)
{